//
//  vdColor.m
//  Void Dead
//
//  Created by Sidney Just on 17.11.09.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//


#import "vdColor.h"

void vdColor_byteToFloat(vdColor *aColor)
{
	if(aColor->alpha > 0)
		aColor->alpha = aColor->alpha/255;
	
	if(aColor->red > 0)
		aColor->red   = aColor->red/255;
	
	if(aColor->green > 0)
		aColor->green = aColor->green/255;
	
	if(aColor->blue > 0)
		aColor->blue  = aColor->blue/255;
}

void vdColor_floatToByte(vdColor *aColor)
{
	aColor->alpha = aColor->alpha*255;
	aColor->red   = aColor->red*255;
	aColor->green = aColor->green*255;
	aColor->blue  = aColor->blue*255;
}

BOOL vdColor_equalToColor(vdColor *color1, vdColor *color2)
{
	if(color1->alpha == color2->alpha && color1->red == color2->red && color1->green == color2->green && color1->blue == color2->blue)
		return YES;
	
	return NO;
}